package cupk.abner;

import cupk.abner.ConcreteComponent.*;

public class ConcreteMediator extends Mediator{
    public Button addButton = new Button();
    public List list = new List();
    public TextBox userNameTextBox = new TextBox();
    public ComboBox cb = new ComboBox();

    @Override
    public void componentChanged(Component c) {
        if(c instanceof Button){
            System.out.println("--单击增加按钮--");
            list.update();
            cb.update();
            userNameTextBox.update();
        }else if(c instanceof List){
            System.out.println("--从列表框选择客户--");
            cb.select();
            userNameTextBox.setText();
        }else if(c instanceof ComboBox){
            System.out.println("--从组合框选择客户--");
            list.select();
            userNameTextBox.setText();
        }else if(c instanceof TextBox){
            System.out.println("--从文本框获取信息--");
            list.select();
            cb.select();
        }else{
            System.out.println("--无效操作--");
        }
    }
}